﻿<Window x:Class="MVVM.WPFView.CustomersView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="clr-namespace:MVVM.ViewModel;assembly=MVVM.ViewModel"
    Title="MVVM AdventureWorks Application." 
    Height="500" Width="700"
    WindowStartupLocation="CenterScreen" WindowState="Normal"
    WindowStyle="ToolWindow">
    <Window.DataContext>
        <vm:CustomersViewModel/>
    </Window.DataContext>
    <!-- BACKGROUND -->
    <Window.Background>
        <ImageBrush ImageSource="Images/account_simple.jpg" Opacity=".5" />
    </Window.Background>
    <DockPanel>
        <!-- TOOLBAR -->
        <DockPanel DockPanel.Dock="Top" MinHeight="30" Margin="5">
            <ToolBar FontWeight="Bold">
                <!-- NEW -->
                <Button Name="btnNew" Command="{Binding Path=NewCommand}">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label FontWeight="Bold" Background="SteelBlue" Foreground="White">
                                Create a new Customer
                            </Label>
                            <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
                            Create a new customer in a new Window tab.
                            </TextBlock>
                            <Line Stroke="SteelBlue" StrokeThickness="1" X2="200" />
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="2" Source="Images/users.png"/>
                                <Label>Press F1 for more help</Label>
                            </StackPanel>
                        </StackPanel>
                    </Button.ToolTip>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/new.png" Width="22" Height="22" Margin="2"/>
                        <Label VerticalAlignment="Center">_New</Label>
                    </StackPanel>
                </Button>
                <!-- SAVE -->
                <Button Name="btnSave" Command="{Binding Path=SaveCommand}">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label FontWeight="Bold" Background="SteelBlue" Foreground="White">
                                Save the current session.
                            </Label>
                            <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
                            Save all the changes done in the application.
                            </TextBlock>
                            <Line Stroke="SteelBlue" StrokeThickness="1" X2="200" />
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="2" Source="Images/dialog-information.png"/>
                                <Label>Press F1 for more help</Label>
                            </StackPanel>
                        </StackPanel>
                    </Button.ToolTip>

                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/save.png" Width="22" Height="22" Margin="2" />
                        <Label VerticalAlignment="Center">_Save</Label>
                    </StackPanel>
                </Button>
                <!-- EDIT -->
                <Button Name="btnEdit" Command="{Binding Path=EditCommand}">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label FontWeight="Bold" Background="SteelBlue" Foreground="White">
                                Edit the current record
                            </Label>
                            <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
                            Edit the current selected Customer.
                            </TextBlock>
                            <Line Stroke="SteelBlue" StrokeThickness="1" X2="200" />
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="2" Source="Images/dialog-information.png"/>
                                <Label>Press F1 for more help</Label>
                            </StackPanel>
                        </StackPanel>
                    </Button.ToolTip>

                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/edit.png" Width="22" Height="22" Margin="2" />
                        <Label VerticalAlignment="Center">_Edit</Label>
                    </StackPanel>
                </Button>
                <!-- DELETE -->
                <Button Name="btnDelete" Command="{Binding Path=DeleteCommand}">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label FontWeight="Bold" Background="SteelBlue" Foreground="White">
                                Delete the current record
                            </Label>
                            <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
                            Delete the current selected Customer and all his orders.
                            </TextBlock>
                            <Line Stroke="SteelBlue" StrokeThickness="1" X2="200" />
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="2" Source="Images/dialog-warning.png"/>
                                <Label>Press F1 for more help</Label>
                            </StackPanel>
                        </StackPanel>
                    </Button.ToolTip>

                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/delete.png" Width="22" Height="22" Margin="2" />
                        <Label VerticalAlignment="Center">_Delete</Label>
                    </StackPanel>
                </Button>
                <Separator />
                <!-- ORDERS -->
                <Button Name="btnOrder" Command="{Binding Path=OrdersCommand}">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label FontWeight="Bold" Background="SteelBlue" Foreground="White">
                                View orders
                            </Label>
                            <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
                            View the orders for the current customer.
                            </TextBlock>
                            <Line Stroke="SteelBlue" StrokeThickness="1" X2="200" />
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="2" Source="Images/dialog-information.png"/>
                                <Label>Press F1 for more help</Label>
                            </StackPanel>
                        </StackPanel>
                    </Button.ToolTip>

                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/paste.png" Width="22" Height="22" Margin="2" />
                        <Label VerticalAlignment="Center">_Orders</Label>
                    </StackPanel>
                </Button>
                <!-- SEARCH -->
                <Separator />
                <TextBox 
                    MinWidth="120" Margin="5"
                    BorderThickness="1" BorderBrush="LightGray"
                    FontWeight="Normal" Foreground="Gray" Text="{Binding Path=SearchText}">

                </TextBox>
                <Button Name="btnSearch" Command="{Binding Path=FindCommand}">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label FontWeight="Bold" Background="SteelBlue" Foreground="White">
                                Search
                            </Label>
                            <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
                            Search a specific Customer.
                            </TextBlock>
                            <Line Stroke="SteelBlue" StrokeThickness="1" X2="200" />
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="2" Source="Images/find.png"/>
                                <Label>Press F1 for more help</Label>
                            </StackPanel>
                        </StackPanel>
                    </Button.ToolTip>

                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/find.png" Width="22" Height="22" Margin="2" />
                        <Label VerticalAlignment="Center">_Find</Label>
                    </StackPanel>
                </Button>
                <!-- EXIT -->
                <Separator />
                <Button Name="btnExit" Command="{Binding Path=ExitCommand}">
                    <Button.ToolTip>
                        <StackPanel>
                            <Label FontWeight="Bold" Background="SteelBlue" Foreground="White">
                                Start the application
                            </Label>
                            <TextBlock Padding="10" TextWrapping="WrapWithOverflow" Width="200">
                            Start the main application with the M-V-MV pattern.
                            </TextBlock>
                            <Line Stroke="SteelBlue" StrokeThickness="1" X2="200" />
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="2" Source="Images/dialog-information.png"/>
                                <Label>Press F1 for more help</Label>
                            </StackPanel>
                        </StackPanel>
                    </Button.ToolTip>

                    <StackPanel Orientation="Horizontal">
                        <Image Source="Images/exit.png" Width="22" Height="22" Margin="2" />
                        <Label VerticalAlignment="Center">_Exit</Label>
                    </StackPanel>
                </Button>
            </ToolBar>
        </DockPanel>
        <!-- LIST -->
        <DockPanel Margin="5">
            <ListView 
                Name="lstCustomers" ItemsSource="{Binding Path=ListOfCustomers}"
                SelectedItem="{Binding Path=SelectedCustomer}" SelectionMode="Single"
                IsSynchronizedWithCurrentItem="True"
                HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                MinHeight="100">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="First Name" Width="200">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=FirstName}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Last Name" Width="200">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=LastName}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Company">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=CompanyName}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
    </DockPanel>
</Window>
